import BASE_URL from '~common/config/base-url'
import {baseService,taskService} from '#/service'
export default {
  methods:{
    imgUrl(url){
      let base= process.env.NODE_ENV === 'development' ? 'https://abc-1256878718.cos.ap-shanghai.myqcloud.com/' : 'https://abc-1256878718.cos.ap-shanghai.myqcloud.com/'
      if(url){
        return base+url
      }
      return url
    },
    domain(){
      if(process.env.NODE_ENV === 'development') return 'http://103.251.90.136:8011/getVerify'
      let host=location.protocol+"//"+window.location.hostname
      host=window.location.port?`${host}:${window.location.port}/getVerify`:host+'/getVerify'
      return host
    },
    async upload(arg, key,prop='submit') {
      let event = arg[0]
      let file = event.target.files[0];
      baseService.clouduplLoadUrl({
        data:file,
        success:(uuid)=>{
          this[prop][key] = uuid.toString()
        }
      })
      // let upload = new Upload(file, {
      //   name: 'file',
      //   options: {
      //     url: `${BASE_URL}/upload`,
      //   }
      // })
      // upload.on('success', (res) => {
      //   try {
      //     res = JSON.parse(res)
      //   } catch (e) {
      //     console.info(e)
      //   }
      //   if (res.code === 0) {
      //
      //   } else {
      //     this.$notify({
      //       title: '警告',
      //       message: res.message,
      //       type: 'warning'
      //     });
      //   }
      //
      // })
      // let data = await upload.send()
    },
  }
}
